import type {NavigationGuardNext, RouteLocationNormalizedGeneric, RouteRecordRaw} from "vue-router";
import {Typography,LayoutDefault} from "@/layouts";
export const routes:RouteRecordRaw[] = [
    {
        path: '/',
        name: 'home',
        redirect: {name: 'preferences'},
    },
    {
        path: '/auth',
        name: 'auth',
        component: LayoutDefault,
        meta: {
            title: '身份验证',
            icon: 'mdi:cog',
            isHidden: true,
            isMenu: false,
            permission: [],
        },
        children: [
            {
                path: 'login',
                name: 'login',
                component: () => import('@/views/auth/login'),
                meta: {
                    title: '用户登录',
                    icon: 'mdi:cog',
                    isHidden: true,
                    isMenu: false,
                    permission: [],
                },
            },
        ]
    },
    {
        path: '/preferences',
        name: 'preferences',
        component: Typography,
        redirect: {name: 'overview'},
        meta: {
            title: '首选项',
            icon: 'mdi:cog',
            isHidden: false,
            isMenu: true,
            permission: [],
        },
        children: [
            {
                path: 'overview',
                name: 'overview',
                component: () => import('@/views/preferences/overview'),
                meta: {
                    title: '统计总览',
                    icon: 'mdi:cog',
                    isHidden: false,
                    isMenu: true,
                    permission: [],
                },
            },
            {
                path: 'dashboard',
                name: 'dashboard',
                component: () => import('@/views/preferences/dashboard'),
                meta: {
                    title: '仪表盘',
                    icon: 'mdi:cog',
                    isHidden: false,
                    isMenu: true,
                    permission: [],
                },
            },
        ],
    },
    {
        path:'/:pathMatch(.*)*',
        name:'notfound',
        component: ()=> import('@/views/errors/notfound/index.tsx'),
        meta: {
            title: '404',
            icon: 'mdi:cog',
            isHidden: true,
            isMenu: false,
            permission: [],
        },
    }
]
export const authorization = (to: RouteLocationNormalizedGeneric, from: RouteLocationNormalizedGeneric,next:  NavigationGuardNext) => {
    document.title = `${to.meta.title} | 城投防汛系统`
    next()
}
